#ifndef DEVICE_DEVICEDX9_H
#define DEVICE_DEVICEDX9_H
#include "../inc/predefine.h"
#include "../inc/device.h"
#include "D3DHeader.h"
namespace Graphic{
	class DeviceDX9 : public Device
	{
	public:
		virtual ~DeviceDX9(){}
		DeviceDX9();
		bool Initial(const CreateParam& );	

	private:
		void InitD3DPP(D3DPRESENT_PARAMETERS& d3dpp);

		D3D9* m_d3d9;
		D3D9Device* m_pDevice;
		D3DPRESENT_PARAMETERS m_d3dParam;

		bool m_bIsValid;

	//interfaces
	public:
		virtual bool IsValid();
		virtual int	 GetHandle();
		virtual void Release();
	public:
		virtual void Clear(int color, int Buffers, float z, float stencil);
		virtual void Present(void* pSrcRect, void*pDstRect, void* hWindow);
		virtual bool Begin();
		virtual void End();
	public:
		virtual VertexBuffer*	CreateVertexBuffer(int size, int usage, const char* data = 0);
		virtual IndexBuffer*	CreateIndexBuffer(int size, int usage, const char* data = 0);

		virtual VertexDecl*		CreateVertexDecl();
		virtual ShaderProgram*	CreateShaderProgram(VertexShader* vs = 0, PixelShader* ps = 0){return 0;};
		virtual VertexShader*	CreateVertexShader(const char* source){return 0;};
		virtual PixelShader*	CreatePixelShader(const char* source){return 0;};
		virtual Texture*		CreateTexture(int width, int height,  int iformat = TF_RGBA, int dformat = TF_BGRA, int dtype = DT_WORD, const char* data = 0){return 0;};
		virtual FrameBuffer*	CreateFrameBuffer(int width, int height){return 0;};

	public:
		virtual void SetVertexBuffer(int index, VertexBuffer* vb, int base = 0);
		virtual void SetIndexBuffer(IndexBuffer* ib);


		virtual void SetVertexDecl(VertexDecl* decl);;

	public:
		virtual void Draw(int type, int begin, int count){};
		virtual void DrawIndexed(int type, int itype, int begin, int count){};
		virtual void DrawRangeIndexed(){};
		virtual void DrawIndexedBase(){};
		virtual void DrawRangeIndexedBase(){};

	public:
		virtual void SetRenderStage(int type, int val){};
	};
}
#endif
